```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>线程池参数优化指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .heading-font {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f8f8f8;
            border-left: 4px solid #667eea;
        }
        .first-letter::first-letter {
            font-size: 3.5rem;
            font-weight: bold;
            float: left;
            line-height: 1;
            margin-right: 0.5rem;
            color: #667eea;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="heading-font text-4xl md:text-6xl font-bold mb-6 animate-fade-in">线程池参数优化指南</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl mx-auto">掌握核心参数配置，构建高性能并发系统</p>
            <div class="flex justify-center space-x-4">
                <a href="#keep-alive" class="bg-white text-indigo-700 hover:bg-gray-100 px-6 py-3 rounded-full font-medium transition-all duration-300 transform hover:scale-105">
                    <i class="fas fa-clock mr-2"></i>存活时间
                </a>
                <a href="#queue-length" class="bg-indigo-800 hover:bg-indigo-700 text-white px-6 py-3 rounded-full font-medium transition-all duration-300 transform hover:scale-105">
                    <i class="fas fa-layer-group mr-2"></i>队列长度
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-6 md:p-8 card-hover">
                <p class="first-letter text-gray-700 text-lg">
                    在配置线程池时，线程池中的存活时间（也称为keep-alive time）和队列长度是两个重要的参数。这些参数的设置取决于具体的应用需求、负载特性和系统资源。
                </p>
            </div>
        </section>

        <!-- Keep-Alive Time Section -->
        <section id="keep-alive" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-100 p-3 rounded-full mr-4">
                    <i class="fas fa-clock text-indigo-600 text-2xl"></i>
                </div>
                <h2 class="heading-font text-3xl font-bold text-gray-800">存活时间（Keep-Alive Time）</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-stopwatch mr-2"></i> 任务的持续时间
                    </h3>
                    <p class="text-gray-700">
                        如果任务的处理时间很短且任务到达频率较低，较短的存活时间可以减少线程池的开销。如果任务的处理时间较长且任务到达频率较高，较长的存活时间可以避免频繁创建和销毁线程带来的性能开销。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-server mr-2"></i> 系统负载和资源
                    </h3>
                    <p class="text-gray-700">
                        在高负载环境中，较长的存活时间可以减少线程的创建和销毁开销，保持线程池中的线程活跃。在资源紧张的环境中，较短的存活时间可以减少资源占用，防止线程池中积累过多的闲置线程。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-wave-square mr-2"></i> 任务的波动性
                    </h3>
                    <p class="text-gray-700">
                        如果任务到达的时间间隔不规律，适当增加存活时间可以防止线程频繁创建和销毁，提供更好的性能。如果任务到达非常规律，可以根据任务的规律性来调整存活时间。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-code mr-2"></i> 代码示例
                    </h3>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto">
<code class="text-sm">// 创建一个线程池，线程闲置60秒后会被终止
ExecutorService executor = new ThreadPoolExecutor(
    corePoolSize,
    maximumPoolSize,
    60L, // 存活时间
    TimeUnit.SECONDS,
    new LinkedBlockingQueue<>()
);</code></pre>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-6 mb-10">
                <h3 class="heading-font text-xl font-semibold mb-6 text-indigo-600">存活时间决策流程图</h3>
                <div class="mermaid">
                    graph TD
                        A[开始] --> B{任务处理时间?}
                        B -->|短| C[较短的存活时间]
                        B -->|长| D[较长的存活时间]
                        C --> E{任务到达频率?}
                        D --> E
                        E -->|低| F[考虑更短存活时间]
                        E -->|高| G[考虑更长存活时间]
                        F --> H[考虑系统负载]
                        G --> H
                        H -->|高负载| I[较长存活时间]
                        H -->|资源紧张| J[较短存活时间]
                </div>
            </div>
        </section>

        <!-- Queue Length Section -->
        <section id="queue-length" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-100 p-3 rounded-full mr-4">
                    <i class="fas fa-layer-group text-indigo-600 text-2xl"></i>
                </div>
                <h2 class="heading-font text-3xl font-bold text-gray-800">队列长度（Queue Length）</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-chart-line mr-2"></i> 任务的到达率
                    </h3>
                    <p class="text-gray-700">
                        如果任务到达率较高，较长的队列可以减少任务被拒绝的概率，但需要适当设置，以防队列过长导致内存消耗过大。如果任务到达率较低，较短的队列可能更适合，可以减少内存占用。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-tachometer-alt mr-2"></i> 任务处理能力
                    </h3>
                    <p class="text-gray-700">
                        如果每个任务处理的时间较长，可以使用较长的队列来平衡任务的处理能力和线程池的线程数量。如果任务处理时间很短，较短的队列可能更适合，减少任务排队的时间。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-memory mr-2"></i> 系统的内存和资源
                    </h3>
                    <p class="text-gray-700">
                        较长的队列会占用更多的内存。如果系统内存资源紧张，需要根据实际情况合理设置队列长度，以防止内存耗尽。在高内存环境下，可以使用较长的队列来提升吞吐量，但要注意避免过多的排队任务导致响应时间延迟。
                    </p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="heading-font text-xl font-semibold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-code mr-2"></i> 代码示例
                    </h3>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto">
<code class="text-sm">// 创建一个线程池，使用一个容量为100的队列
ExecutorService executor = new ThreadPoolExecutor(
    corePoolSize,
    maximumPoolSize,
    keepAliveTime,
    TimeUnit.SECONDS,
    new LinkedBlockingQueue<>(100) // 队列长度
);</code></pre>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-6">
                <h3 class="heading-font text-xl font-semibold mb-6 text-indigo-600">队列长度决策矩阵</h3>
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-gray-50">
                            <tr>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">场景</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">高到达率</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">低到达率</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">长处理时间</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">短处理时间</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">推荐队列长度</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">较长</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">较短</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">较长</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">较短</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">内存考虑</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">需要监控</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">低风险</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">需要监控</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">低风险</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="bg-indigo-50 rounded-xl p-8 mb-20">
            <h2 class="heading-font text-2xl font-bold text-indigo-800 mb-6">关键总结</h2>
            <div class="grid md:grid-cols-2 gap-6">
                <div>
                    <h3 class="heading-font text-lg font-semibold text-indigo-700 mb-3 flex items-center">
                        <i class="fas fa-check-circle mr-2"></i> 存活时间最佳实践
                    </h3>
                    <ul class="space-y-2 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>短任务+低频率 → 短存活时间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>长任务+高频率 → 长存活时间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>不规则任务 → 适度延长存活时间</span>
                        </li>
                    </ul>
                </div>
                <div>
                    <h3 class="heading-font text-lg font-semibold text-indigo-700 mb-3 flex items-center">
                        <i class="fas fa-check-circle mr-2"></i> 队列长度最佳实践
                    </h3>
                    <ul class="space-y-2 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>高到达率 → 较长队列</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>低内存 → 较短队列</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right text-indigo-500 text-xs mt-1 mr-2"></i>
                            <span>长处理时间 → 平衡队列和线程数</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto max-w-5xl px-4 text-center">
            <div class="flex flex-col items-center">
                <h3 class="heading-font text-xl font-bold mb-4">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition-colors duration-300">
                    <i class="fas fa-globe mr-2"></i> www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```